//
//  FootView.swift
//  weibo1
//
//  Created by Apple on 15/12/1.
//  Copyright © 2015年 Apple. All rights reserved.
//

import UIKit
import SnapKit

class FootView: UIView {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //
    func setupUI(){
        addSubview(retweetBut)
        addSubview(commentBut)
        addSubview(unlikeBut)
        //设置布局
        retweetBut.snp_makeConstraints { (make) -> Void in
            make.top.left.bottom.equalTo(self)
        }
        commentBut.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetBut.snp_right)
            make.top.bottom.equalTo(self)
            make.width.equalTo(retweetBut.snp_width)
        }
        
        unlikeBut.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBut.snp_right)
            //三等分的第一个条件 添加右边约束
            make.right.equalTo(self)
            make.width.equalTo(commentBut.snp_width)
            make.top.bottom.equalTo(self)
        }
        //竖线view的约束
        let view1 = sepview()
        let view2 = sepview()
        let w = 0.5
        let scale = 0.4
        addSubview(view1)
        addSubview(view2)
        
        view1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetBut.snp_right)
            make.width.equalTo(w)
            make.centerY.equalTo(self.snp_centerY)
            make.height.equalTo(self.snp_height).multipliedBy(scale)
        }
        view2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBut.snp_right)
            make.width.equalTo(w)
            make.centerY.equalTo(self.snp_centerY)
            make.height.equalTo(self.snp_height).multipliedBy(scale)
        }
    }
    
    //添加view竖线
    private func sepview() -> UIView {
        let view = UIView()
        view.backgroundColor = UIColor.darkGrayColor()
        return view
    }
    
    //MARK: 懒加载子视图
    private lazy var retweetBut :UIButton = {
        let but = UIButton()
        but.setTitle("转发", forState: .Normal)
        but.setImage(UIImage(named: "timeline_icon_retweet"), forState: .Normal)
        but.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        but.titleLabel?.font = UIFont.systemFontOfSize(10)
        return but
        }()
    private lazy var commentBut :UIButton = {
        let but = UIButton()
        but.setTitle("评论", forState: .Normal)
        but.setImage(UIImage(named: "timeline_icon_comment"), forState: .Normal)
        but.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        but.titleLabel?.font = UIFont.systemFontOfSize(10)
        return but
        }()
    private lazy var unlikeBut :UIButton = {
        let but = UIButton()
        but.setTitle("赞", forState: .Normal)
        but.setImage(UIImage(named: "timeline_icon_unlike"), forState: .Normal)
        but.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        but.titleLabel?.font = UIFont.systemFontOfSize(10)
        
        return but
        }()
    
}
